use Dosvid
go

if exists(select 1
		  from sysobjects
		  where name = 'Employer_CommodityGroups')
  drop table Employer_CommodityGroups
go

create table Employer_CommodityGroups
(
  Id int identity(1,1) not null,
  EmployerId int not null,
  CommodityGroupId int not null
)  
go

alter table Employer_CommodityGroups add constraint PK_Employer_CommodityGroups_ID primary key(Id) 
go


alter table Employer_CommodityGroups add constraint FK_Employer_CommodityGroups_CommodityGroups_CommodityGroupId 
      foreign key (CommodityGroupId) references CommodityGroups(Id) on delete cascade
go


alter table Employer_CommodityGroups add constraint FK_Employer_CommodityGroups_Employers_EmployerId 
      foreign key (EmployerId) references Employers(Id) on delete cascade
go


create nonclustered index IX_Employer_CommodityGroups_EmployerId on Employer_CommodityGroups
       (EmployerId asc)
go
